package cn.bytecollege.admin.controller; /**
 * @Auther：MR.P
 * @Date:2021/10/28 19 07
 * @Description:根据id查找支付方式请求到修改页面
 */

import cn.bytecollege.admin.service.PaymentService;
import cn.bytecollege.common.entity.Payment;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "PaymentFindController", value = "/admin/paymentFind")
public class PaymentFindController extends HttpServlet {
    private PaymentService paymentService = null;
    public PaymentFindController(){
        paymentService = new PaymentService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("paymentId");
        Integer paymentId  = Integer.valueOf(id);
        //根据id查询支付方式
        Payment payment = paymentService.findById(paymentId);
        request.setAttribute("payment",payment);
        request.getRequestDispatcher("/admin/html/device/paymentUpdate.jsp").forward(request,response);
    }
}
